<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>添加管理员</title>
    <link href="assets/css/bootstrap.min.css" rel="stylesheet"/>
    <link rel="stylesheet" href="css/style.css"/>
    <link href="assets/css/codemirror.css" rel="stylesheet">
    <link rel="stylesheet" href="assets/css/ace.min.css"/>
    <link rel="stylesheet" href="font/css/font-awesome.min.css"/>
    <link rel="stylesheet" href="assets/css/ace-ie.min.css"/>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
    <script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.js"></script>
</head>
<body>

<div id="app" class="add_menber">
    <div class="form-group">
        <label class="form-label"><span class="c-red">*</span>姓名：</label>
        <div class="formControls">
            <input type="text" v-model.trim="Adminname" class="input-text" value="" placeholder="" id="user-name"
                   name="user-name" datatype="*2-16" nullmsg="用户名不能为空">
        </div>
        <div class="col-4"><span class="Validform_checktip"></span></div>
    </div>
    <div class="form-group">
        <label class="form-label"><span class="c-red">*</span>初始密码：</label>
        <div class="formControls">
            <input type="password" placeholder="密码" name="userpassword" autocomplete="off" value="" class="input-text"
                   datatype="*6-20" nullmsg="密码不能为空">
        </div>
        <div class="col-4"><span class="Validform_checktip"></span></div>
    </div>
    <div class="form-group">
        <label class="form-label "><span class="c-red">*</span>确认密码：</label>
        <div class="formControls ">
            <input type="password" v-model.trim="password" placeholder="确认新密码" autocomplete="off"
                   class="input-text Validform_error" errormsg="您两次输入的新密码不一致！" datatype="*" nullmsg="请再输入一次新密码！"
                   recheck="userpassword" id="newpassword2" name="newpassword2">
        </div>
        <div class="col-4"><span class="Validform_checktip"></span></div>
    </div>

    <div class="form-group">
        <label class="form-label " ><span class="c-red">*</span>手机：</label>
        <div class="formControls ">
            <input v-model.trim="phone" type="text" class="input-text">
        </div>
        <!--        <div class="col-4"><span class="Validform_checktip"></span></div>-->
    </div>
    <!--    <div class="form-group">-->
    <!--        <label class="form-label " ><span class="c-red">*</span >头像：</label>-->
    <!--        <div class="formControls ">-->
    <!--            &lt;!&ndash;             <input type="text" class="input-text" value="" placeholder="" id="user-tel" name="user-tel" datatype="m" nullmsg="手机不能为空">&ndash;&gt;-->
    <!--            <input type="file"/>-->
    <!--        </div>-->
    <!--        <div class="col-4"><span class="Validform_checktip"></span></div>-->
    <!--    </div>-->
    <div class="form-group">
        <label class="form-label">角色：</label>
        <div class="formControls "> <span class="select-box" style="width:150px;">
				<select @change="faultTypeName($event)" class="select" name="admin-role" size="1">
                <option v-for="adminType  in adminTypes" selected>{{adminType.title}}</option>

				</select>
				</span></div>
    </div>
    <div class="form-group">
        <label class="form-label">备注：</label>
        <div class="formControls">
            <textarea name="" cols="" rows="" class="textarea" placeholder="说点什么...100个字符以内" dragonfly="true"
            ></textarea>
            <span class="wordage">剩余字数：<span id="sy" style="color:Red;">100</span>字</span>
        </div>
        <div class="col-4"></div>
    </div>
    <div>
        <!--        <input class="btn btn-primary radius" type="submit" id="Add_Administrator" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">-->
        <button @click="save">添加</button>

    </div>
</div>

</body>
</html>

<script>
    var app = new Vue({
        el: "#app",
        data: {
            password:"",
           Adminname:"",
            phone:"",
            adminTypes:{},
            admin:{},
            adminTypeId:''
        },
        created: function () {
            axios.post("http://localhost:8080/manage/adminType/findAll").
            then(res=>{
                this.adminTypes=res.data.data;
                console.log(this.adminType)
            })

        },
        /**
         * 添加管理员
         * @author 张晓峰
         * @date 2021-6-21
         */
        methods: {
            save: function () {

                alert(this.password)
                alert(this.Adminname)
                alert("添加成功！")

                axios.post("http://localhost:8080/manage/adminType/addAdmin?password=",this.password+"&name"+this.Adminname+"&phone="+this.phone+"&adminTypeId="+this.adminTypeId)
                    .then(res=>{
                            console.log(res.data.message)
                        }

                    )
            },

            faultTypeName($event){
                var adminTypeName = event.target.value;
                axios.post("http://localhost:8080/manage/adminType/findAdminTypeByadminTypeName?adminTypeName="+adminTypeName).
                then(res=>{
                    this.adminTypeId=res.data.data;
                    alert(this.adminTypeId)

                })

            }

        }

    })
</script>